#e
#Title[û͂̎􂢁v]
#Text[܂]
#BackGround[User(.\img\back1.png,0,0)]
#BGM[.\bgm\bgm.mp3]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
	#include_function ".\lib\lib_anime_mokou.txt"
	#include_function ".\Draw.txt"
	#include_function ".\lib_Functions.txt"
	let imgBoss	=csd ~ "img\dot_mokou.png";
	let Back	=csd~"img\back2.png";

	@Initialize {
        	SetLife(800);
		SetTimer(60);
		SetScore(800000);
		SetDamageRate(0, 0);
		InitializeAction();
		LoadUserShotData(shotData);
		LoadGraphic(imgBoss);
		LoadGraphic(Back);
		Load;
		Expert
        	CutIn(YOUMU,"û͂̎􂢁v", NULL, 0, 0, 0, 0);
        	Main;
	}

    	@MainLoop {
        	SetCollisionA(GetX, GetY, 32);
        	SetCollisionB(GetX, GetY, 16);
		if(GetTimer==10&&counter==0){
			Timer;
			counter++;
		}
        	yield;
    	}

	@DrawLoop {
		SetColor(255,255,255);
		SetGraphicScale(1,1);
		SetAlpha(255);
		DrawBoss(imgBoss);
	}

	@BackGround {
		SetColor(100,100,255);
		SetTexture(Back);
		SetGraphicRect(0, 0, 384, 457);
		SetGraphicAngle(0, 0, 0);
		DrawGraphic(224, 240);
		if(drawcount==1){
			DrawHououZ(200, 200, 100, 100);
		}
		if(drawcount>0){
			DrawHouou(200, 200, 100, 100);
			DrawIrusion(GetX, GetY,100,255,100,100);
		}
	}

	sub standBy {
		SetMovePosition03(cenX,cenY-120, 10, 7);
		SetAction(ACT_MOVE, 60);
		wait(120);
	}


   	task Main {
        	yield;
		standBy;
		Charge;
		PlaySE(seCharge1);
		wait(30);
		drawcount++;
		wait(30);
		drawcount++;
		wait(60);
		SetDamageRate(20, 10);	
		Att;
	}

	task Att{
		shotA;
		shotB;
	}

	task shotA{
		let B=0;
		loop{
		wait(7);
		let angleA=0;
		while(angleA<360){
		CreateShot01(GetX,GetY,2.5,angleA-B,45,0);
		angleA+=45;
		}
		B+=2;
		}
	}

	task shotB{
		let B=-40;
		loop{
		wait(20);
		let angleA=0;
		while(angleA<360){
		CreateReflectShot(GetX,GetY,2.5,angleA+B,150,0,1);
		angleA+=90;
		}
		PlaySE(seShot5);
		B+=8;
		}
	}

	task CreateReflectShot(let x, let y, let speed,
        	let angle, let graphic, let delay, let count) {
    
    		let Obj = Obj_Create(OBJ_SHOT);
    
   		Obj_SetPosition(Obj, x, y);
   	 	Obj_SetSpeed(Obj, speed);
    		Obj_SetAngle(Obj, angle);
    		ObjShot_SetGraphic(Obj, graphic);
    		ObjShot_SetDelay(Obj, delay);

    
    		while(!Obj_BeDeleted(Obj)) {
        		if(((Obj_GetX(Obj)-GetX)^2+(Obj_GetY(Obj)-GetY)^2)^0.5>300){
	    		let a=0;
	    		loop(1){
	    		loop(11){
	    		Obj_SetSpeed(Obj,speed-a);
	    		a+=2.5/10;
	    		wait(4)
	    		}
	    		wait(10);
	    		let mi=GetPlayerX;
	    		let me=GetPlayerY;
            		Obj_SetAngle(Obj, atan2(me-Obj_GetY(Obj),mi-Obj_GetX(Obj)));
	    		Obj_SetSpeed(Obj, 0.6);
	    		ObjShot_SetGraphic(Obj, graphic-5);    
            		count--;
	    		}
        	}

        	if(count<=0){ break; }
    
        	yield;
    		}
	}

	@Finalize{
		DeleteGraphic(imgBoss);
		Delete;
	}

}